#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    bool evaluateTree(TreeNode* root) {
        if (root->left == nullptr)
        {
            if (root->val == 0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
        if (root->val == 2)
        {
            return evaluateTree(root->left) || evaluateTree(root->right);
        }
        else
        {
            return evaluateTree(root->left) && evaluateTree(root->right);
        }
    }
};